import { Component } from 'react';
import { withRouter } from 'umi';
import 'moment/locale/zh-cn';
import type { Props } from '@/layout';

class ScrollToTop extends Component<Props> {
  componentDidUpdate(prevProps: { location: { pathname: string } }) {
    if (this.props.location.pathname !== prevProps.location.pathname) {
      window.scrollTo(0, 0);
    }
  }

  render() {
    return this.props.children;
  }
}
export default withRouter(ScrollToTop as any);
